package com.patelski.magic.model;

// Generated 23-jan-2008 16:17:12 by Hibernate Tools 3.2.0.b10

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Lob;
import javax.persistence.Transient;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Employee generated by hbm2java
 */
@Entity
@Table(name = "CARDS")
public class Card implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1506900589404205913L;
	private Integer id;
	private String cardName;
	private Edition edition;
	private String rarity;
	// private String color;
	private Color color;
	private String cost;
	private String powerToughness;
	private String type;
	private String text;
	private String flavor;
	private String artist;
	private Integer collectorNumber;
//	private String foil;
	private Foil foil;
	private String picture;

	public Card() {
	}

	public Card(String cardName, Edition edition,
			String rarity,
			// String color,
			Color color, String cost, String powerToughness, String type,
			String text, String flavor, String artist, Integer collectorNumber,
//			String foil, 
			Foil foil, 
			String picture) {
		this.cardName = cardName;
		this.edition = edition;
		this.rarity = rarity;
		this.color = color;
		this.cost = cost;
		this.powerToughness = powerToughness;
		this.type = type;
		this.text = text;
		this.flavor = flavor;
		this.artist = artist;
		this.collectorNumber = collectorNumber;
		this.foil = foil;
		this.picture = picture;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "CARD_NAME", nullable = false, length = 150)
	@NotNull
	@Length(max = 150)
	public String getCardName() {
		return this.cardName;
	}

	public void setCardName(String cardName) {
		this.cardName = cardName;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "EDITION", nullable = false)
	@NotNull
	public Edition getEdition() {
		return edition;
	}

	public void setEdition(Edition edition) {
		this.edition = edition;
	}

	@Column(name = "RARITY", nullable = true, length = 4)
	@Length(max = 4)
	public String getRarity() {
		return rarity;
	}

	public void setRarity(String rarity) {
		this.rarity = rarity;
	}

	// @Column(name = "COLOR", nullable = true, length = 10)
	// @Length(max = 10)
	// public String getColor() {
	// return color;
	// }

	@Column(name = "COLOR", nullable = true, insertable = true, updatable = true, columnDefinition = "VARCHAR(10)")
	@Enumerated(EnumType.STRING)
	public Color getColor() {
		return color;
	}

	// public void setColor(String color) {
	// this.color = color;
	// }

	public void setColor(Color color) {
		this.color = color;
	}

	@Column(name = "COST", nullable = true, length = 50)
	@Length(max = 50)
	public String getCost() {
		return cost;
	}

	public void setCost(String cost) {
		this.cost = cost;
	}

	@Column(name = "P_T", nullable = true, length = 10)
	@Length(max = 10)
	public String getPowerToughness() {
		return powerToughness;
	}

	public void setPowerToughness(String powerToughness) {
		this.powerToughness = powerToughness;
	}

	@Column(name = "TYPE", nullable = true, length = 45)
	@Length(max = 45)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "TEXT", columnDefinition = "text")
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@Column(name = "FLAVOR", columnDefinition = "text")
	public String getFlavor() {
		return flavor;
	}

	public void setFlavor(String flavor) {
		this.flavor = flavor;
	}

	@Column(name = "ARTIST", nullable = true, length = 45)
	@Length(max = 45)
	public String getArtist() {
		return artist;
	}

	public void setArtist(String artist) {
		this.artist = artist;
	}

	@Column(name = "COLLECTOR_NUMBER", nullable = true)
	public Integer getCollectorNumber() {
		return collectorNumber;
	}

	public void setCollectorNumber(Integer collectorNumber) {
		this.collectorNumber = collectorNumber;
	}

//	@Column(name = "FOIL", nullable = true, length = 2)
//	@Length(max = 2)
//	public String getFoil() {
//		return foil;
//	}
//
//	public void setFoil(String foil) {
//		this.foil = foil;
//	}


	@Column(name = "FOIL", nullable = true, insertable = true, updatable = true, columnDefinition = "VARCHAR(2)")
	@Enumerated(EnumType.STRING)
	public Foil getFoil() {
		return foil;
	}

	public void setFoil(Foil foil) {
		this.foil = foil;
	}

	
	@Column(name = "PICTURE", nullable = true, length = 45)
	@Length(max = 45)
	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}
	
	@Transient
	public String getCardNameEncoded() {
		String result = "";
		
		result = getCardName();
		result = result.replaceAll("\\s", "%20");
		return result;
	}
	
	public void setCardNameEncoded(String cardNameEncoded) {
		
	}

}
